// $Id$

using System;
using Salamanca;
using Salamanca.DataActivities;

namespace Northwind.Activities.OrderCreateNew
{
    public interface IData:
        IActivityData,
        DomainModel.ICustomerContainer,
        DomainModel.IOrderContainer,
        IDataBag<DomainModel.Customer>,
        IDataBag<DomainModel.Order>
    {
    }

    public class Data:
        ActivityData,
        IData
    {
        private struct Backup
        {
            public object Customer;
            public object Order;
        }

        public Data()
        {
        }

        protected override object CreateBackup()
        {
            Backup ret=new Backup();
            if (_Customer!=null)
                ret.Customer=((IBackupable)_Customer).CreateBackup();
            if (_Order!=null)
                ret.Order=((IBackupable)_Order).CreateBackup();
            return ret;
        }

        protected override void RestoreBackup(object backup)
        {
            if (((Backup)backup).Customer!=null)
                ((IBackupable)_Customer).RestoreBackup(((Backup)backup).Customer);
            if (((Backup)backup).Order!=null)
                ((IBackupable)_Order).RestoreBackup(((Backup)backup).Order);
        }

        public DomainModel.Customer Customer
        {
            get
            {
                return _Customer;
            }
            set
            {
                _Customer=value;
            }
        }

        DomainModel.Customer IDataBag<DomainModel.Customer>.Data
        {
            get
            {
                return Customer;
            }
            set
            {
                Customer=value;
            }
        }

        public DomainModel.Order Order
        {
            get
            {
                return _Order;
            }
            set
            {
                _Order=value;
            }
        }

        DomainModel.Order IDataBag<DomainModel.Order>.Data
        {
            get
            {
                return Order;
            }
            set
            {
                Order=value;
            }
        }

        private DomainModel.Customer _Customer;
        private DomainModel.Order _Order;
    }

}
